import 'package:flutter/material.dart';
import 'package:flutter_douban/config/Http_service.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/main_page/store/view/commit_cell.dart';
import 'package:flutter_douban/model/store_product_detail_model.dart';
import 'package:flutter_douban/tool_views/back_nav_btn.dart';
import 'package:flutter_douban/tool_views/nav_title_page.dart';

class StoreCommitListPage extends StatefulWidget {
  const StoreCommitListPage({Key? key}) : super(key: key);

  @override
  _StoreCommitListPageState createState() => _StoreCommitListPageState();
}

class _StoreCommitListPageState extends State<StoreCommitListPage> {
  late StoreProductDetailModel _storeProductDetailModel;

  Future _getListData() async {
    try {
      /// 全部数据
      Map<String, dynamic> result = await HttpService.getMockDataWithPath(
          path: 'mock/store_commit_list_data.json');
      StoreProductDetailModel storeProductDetailModel =
      StoreProductDetailModel.fromJson(result['result']);
      setState(() {
        _storeProductDetailModel = storeProductDetailModel;
      });

      /// 结束加载状态
    } catch (e) {
      print(e);
    } finally {}
  }

@override
  void initState() {
    // TODO: implement initState
    super.initState();
    _getListData();
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: BackNavBtn(),
        title: NavTitlePage(titleStr: "评价晒单",),
      ),
      body: Container(
        color: Colors.white,
        padding: EdgeInsets.only(left: 20,right: 20,top: 10),
        child: ListView.builder(
          itemCount: _storeProductDetailModel.sos!.length,
          itemBuilder: (context, index) {
            return ProductDetailCommitCell(model: _storeProductDetailModel.sos![index],);
          },
        ),
      ),
    );
  }
}
